package Myenum;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-04-28
 * Time：20:41
 */
public enum MyEnum {
    ONE(1,"第一位顾客") , TWO(2,"第二位大佬") , THREE(3,"第三位少爷"),FOUR(4,"第四位先生");


    int id;
    String nm;

    MyEnum(int id, String nm) {
        this.id=id;
        this.nm=nm;
    }


    public static void func() {
        MyEnum[] myEnums=MyEnum.values();
        for (int i=0; i<myEnums.length;i++) {
            System.out.println("[ id="+myEnums[i].id+" ,nm= "+ myEnums[i].nm+"]");
        }

    }

    public static void main(String[] args) {
        MyEnum myEnum=  THREE;

        System.out.println("==== 用枚举来分支不同情况 ======");
        switch (myEnum) {
            case ONE :
                System.out.println("ONE");
                break;
            case TWO :
                System.out.println("TWO");
                break;
            case THREE :
                System.out.println("THREE");
                break;
            case FOUR :
                System.out.println("FOUR");
                break;
        }


        System.out.println("===== 实例化枚举类型来打印 =======");
        func();

    }
}
